import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MailAccountVO, MailAccountForm, MailAccountQuery } from '@/api/mail/account/types';

/**
 * 查询邮箱账号列表
 * @param query
 * @returns {*}
 */

export const listMailAccount = (query?: MailAccountQuery): AxiosPromise<MailAccountVO[]> => {
  return request({
    url: '/system/mailAccount/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询邮箱账号详细
 * @param id
 */
export const getMailAccount = (id: string | number): AxiosPromise<MailAccountVO> => {
  return request({
    url: '/system/mailAccount/' + id,
    method: 'get'
  });
};

/**
 * 新增邮箱账号
 * @param data
 */
export const addMailAccount = (data: MailAccountForm) => {
  return request({
    url: '/system/mailAccount',
    method: 'post',
    data: data
  });
};

/**
 * 修改邮箱账号
 * @param data
 */
export const updateMailAccount = (data: MailAccountForm) => {
  return request({
    url: '/system/mailAccount',
    method: 'put',
    data: data
  });
};

/**
 * 删除邮箱账号
 * @param id
 */
export const delMailAccount = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/mailAccount/' + id,
    method: 'delete'
  });
};

export const getSimpleMailAccountList = () => {
  return request({
    url: '/system/mailAccount/list-all-simple',
    method: 'get',
  })
}
